/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FrmPresentacion.java
 *
 * Created on 01-12-2014, 09:14:10 AM
 */
package Presentacion;

/**
 *
 * @author Estudiante
 */

import Negocio.Entero;
import javax.swing.JOptionPane;
public class FrmPresentacion extends javax.swing.JFrame {

    /** Creates new form FrmPresentacion */
    public FrmPresentacion() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        NumPar = new javax.swing.JButton();
        txtNumeroPar = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        btnPrimo = new javax.swing.JButton();
        btnFactorial = new javax.swing.JButton();
        btnCapicua = new javax.swing.JButton();
        eliminarprimo = new javax.swing.JButton();
        btnFibonacci = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        NumPar.setText("par");
        NumPar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                NumParActionPerformed(evt);
            }
        });

        jLabel1.setText("introducir numero ");

        btnPrimo.setText("primo");
        btnPrimo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPrimoActionPerformed(evt);
            }
        });

        btnFactorial.setText("factorial");
        btnFactorial.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnFactorialActionPerformed(evt);
            }
        });

        btnCapicua.setText("capicua");
        btnCapicua.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCapicuaActionPerformed(evt);
            }
        });

        eliminarprimo.setText("eliminarprimo");
        eliminarprimo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                eliminarprimoActionPerformed(evt);
            }
        });

        btnFibonacci.setText("fibonacci");
        btnFibonacci.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnFibonacciActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(35, 35, 35)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(eliminarprimo)
                        .addGap(18, 18, 18)
                        .addComponent(btnFibonacci))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(btnPrimo))
                        .addGap(35, 35, 35)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(txtNumeroPar, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(NumPar))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(btnFactorial)
                                .addGap(47, 47, 47)
                                .addComponent(btnCapicua)))))
                .addGap(56, 56, 56))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(47, 47, 47)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtNumeroPar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(NumPar)
                    .addComponent(jLabel1))
                .addGap(52, 52, 52)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnPrimo)
                    .addComponent(btnFactorial)
                    .addComponent(btnCapicua))
                .addGap(49, 49, 49)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(eliminarprimo)
                    .addComponent(btnFibonacci))
                .addContainerGap(83, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void NumParActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NumParActionPerformed
        // TODO add your handling code here:
        
        
        Entero objEntero=new Entero();
        objEntero.setNum(Integer.parseInt(this.txtNumeroPar.getText()));
        if(objEntero.Par()){
        JOptionPane.showMessageDialog(null, "El numero es par");}
        else{
         JOptionPane.showMessageDialog(null, "El numero  no es par");
        }
        
    }//GEN-LAST:event_NumParActionPerformed

    private void btnPrimoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPrimoActionPerformed
        // TODO add your handling code here:
        
        
        Entero objEntero=new Entero();
        objEntero.setNum(Integer.parseInt(this.txtNumeroPar.getText()));
        if(objEntero.primo()){
        JOptionPane.showMessageDialog(null, "El numero es primo");}
        else{
         JOptionPane.showMessageDialog(null, "El numero  no es primo");
        }
    }//GEN-LAST:event_btnPrimoActionPerformed

    private void btnFactorialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFactorialActionPerformed
        // TODO add your handling code here:
        
        Entero objEntero=new Entero();
        objEntero.setNum(Integer.parseInt(this.txtNumeroPar.getText()));
        {
        JOptionPane.showMessageDialog(null, "El numero es primo"+ objEntero.factorial());
      
       
        }
    }//GEN-LAST:event_btnFactorialActionPerformed

    private void btnCapicuaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCapicuaActionPerformed
        // TODO add your handling code here:
        Entero objEntero=new Entero();
        objEntero.setNum(Integer.parseInt(this.txtNumeroPar.getText()));
        if(objEntero.capicua()){
        JOptionPane.showMessageDialog(null, "El numero es capicua" );}
        else{
         JOptionPane.showMessageDialog(null, "El numero  no es capicua");
        }
    }//GEN-LAST:event_btnCapicuaActionPerformed

    private void eliminarprimoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_eliminarprimoActionPerformed
        // TODO add your handling code here:
        
        Entero objEntero=new Entero();
        objEntero.setNum(Integer.parseInt(this.txtNumeroPar.getText()));
       {
        JOptionPane.showMessageDialog(null, "El numero primo"+objEntero.EliminarDigitoPrimo() );}
       
         
        
    }//GEN-LAST:event_eliminarprimoActionPerformed

    private void btnFibonacciActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFibonacciActionPerformed
        // TODO add your handling code here:
         Entero objEntero=new Entero();
        objEntero.setNum(Integer.parseInt(this.txtNumeroPar.getText()));
       {
        JOptionPane.showMessageDialog(null, "serie fibonaci"+objEntero.fibonacci());}
       
    }//GEN-LAST:event_btnFibonacciActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new FrmPresentacion().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton NumPar;
    private javax.swing.JButton btnCapicua;
    private javax.swing.JButton btnFactorial;
    private javax.swing.JButton btnFibonacci;
    private javax.swing.JButton btnPrimo;
    private javax.swing.JButton eliminarprimo;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JTextField txtNumeroPar;
    // End of variables declaration//GEN-END:variables
}
